package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;

import com.hjq.shape.view.ShapeTextView;
import com.hjq.widget.layout.WrapRecyclerView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.LearningApi;

/**
 *    author : Android CRG
 *    time   : 2018/11/05
 */
public final class LearningAdapter extends AppAdapter<LearningApi.Bean.ListDTO> {

    public LearningAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvTime;
        private ShapeTextView mTvContent;
        private WrapRecyclerView mRvImg;
        private ImgListAdapter adapter;




        private ViewHolder() {
            super(R.layout.item_learning);
            mTvTime = findViewById(R.id.tv_time);
            mTvContent = findViewById(R.id.tv_content);
            mRvImg = findViewById(R.id.rv_img);
            mRvImg.setLayoutManager(new GridLayoutManager(getContext(),3));
            adapter = new ImgListAdapter(getContext());
            mRvImg.setAdapter(adapter);
        }

        @Override
        public void onBindView(int position) {
            mTvTime.setText(getItem(position).getCreate_time());
            mTvContent.setText(getItem(position).getContent());
            adapter.setData(getItem(position).getImg_url());
        }
    }
}